package com.learn;

import org.springframework.boot.SpringBootConfiguration;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Conditional;

/**
 * conditional 基于条件的自动配置，一般配合condition接口一起使用，只有接口的实现类返回true时才装配，否则不装配 
 * 可以用在类和方法上
 * @author Romanceling
 *
 */
@SpringBootConfiguration
//@Conditional(UTF8Condition.class)
@Conditional({UTF8Condition.class,GBKCondition.class})//数组用法时都返回true时才会装配
public class EncodingConvertConfig {

	@Bean
	@Conditional(UTF8Condition.class)
	public EncodingConvert createEncodingConvert() {
		return new UTF8EncodingConvert();
	}
	
	@Bean
	@Conditional(GBKCondition.class)
	public EncodingConvert createGBKEncodingConvert() {
		return new GBKEncodingConvert();
	}
}
